import { cors } from '@elysiajs/cors';

import { config } from '@/config';

/**
 * 创建 CORS 配置
 */
export function createCorsConfig() {
  return cors({
    origin: config.CORS_ORIGIN,
    methods: config.CORS_METHODS,
    allowedHeaders: config.CORS_ALLOWED_HEADERS,
    exposeHeaders: config.CORS_EXPOSE_HEADERS,
    credentials: config.CORS_CREDENTIALS,
    maxAge: config.CORS_MAX_AGE,
    preflight: config.CORS_PREFLIGHT,
  });
}
